{extend name="public/base" /}

{block name="title"}<title>固定积分配置分类</title>{/block}

{block name="pjax_container"}
<style>
  tr>th,
    td {
        text-align: center;
    }

    .btn-group-xs>.btn,
    .btn-xs {
        padding: 5px;
        margin: 0 5px;
    }
          
.content-header>.breadcrumb>li{
    color: #999;
}
.content-header>.breadcrumb>.active{
    color: #666;
}
.content-header{
    height: 51px;
 
}
.btn-primary{
      background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 5px 10px; 
    line-height: 24px;
}
.box-primary{
  border-top-color: #ecf0f5 !important;
  border-top-width: 16px;
  
}
.btn-primary:hover{
     background-color: #1890FF;
    color: #fff;
    border: none;
    opacity: .9;
    border-radius: 6px !important; 
}
.delete-one{
    background-color: ff4141 !important;
    margin-left: 15px;
    border-radius: 6px;
}
.sreachs{
       background-color: #1890FF;
    color: #fff;
    border: none;
    border-radius: 6px !important;
    margin-left: 15px;
    padding: 7px 15px; 
}
.type_explode{
    color: #fff;
    background-color: #d9534f;
    border-radius: 6px;
    border: none;
}
</style>
<section class="content-header">
    <ol class="breadcrumb">
        <li>积分管理</li>
        <li>固定积分配置</li>
        <li class="active">固定积分配置分类</li>
    </ol>
</section>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box box-primary">
                <div class="box-header with-border">
                    <div class="pull-left">
                        <a href="{:url('fixed')}" class="btn btn-sm task_nav_an"><i class="fa fa-save"></i> 查看配置列表</a>
                        <a href="{:url('fixed_cate')}" class="btn btn-sm task_nav_an task_nav_an_active"><i class="fa fa-save"></i> 查看配置分类</a>
                        <a href="/company/integral/fixed_cate_edit" class="btn btn-sm btn-primary xzrw"><i class="fa fa-save"></i> 新增</a>
                    </div>
                </div>
                <div class="box-body table-responsive">

                     <!-- 事件分类树  -->
                    <link rel="stylesheet" href="__STATIC__/global/an_tree_css/an_tree_css.css">
                    <div class="an_tree organization_index">

                    </div>
                    <!-- 事件分类树   -->
                    
                    <!-- <table class="table table-bordered table-hover">
                        <tr>
                            <th>名称</th>
                            <th>上级分类</th>
                            <th>操作</th>
                        </tr>
                        {volist name="$list" id="v"}
                        <tr>
                            <td>{$v["name"]}</td>
                            <td>{$v["name_p"]}</td>
                            <td>
                                {:authAction(CONTROLLER_NAME.'/fixed_cate_edit','edit',['id'=>$v['id']])}
                                {:authAction(CONTROLLER_NAME.'/fixed_cate_del','delete_one',['id'=>$v['id']])}
                            </td>
                        </tr>
                        {/volist}
                    </table> -->
                </div>
                <div class="box-footer clearfix">
                    {$list->render()}
                </div>
            </div>
        </div>
    </div>
</section>
<script>
    $(function(){
        // 列表部分 全选
        $('input[type="checkbox"].minimal, input[type="radio"].minimal').iCheck({
            checkboxClass: 'icheckbox_minimal-blue',
            radioClass: 'iradio_minimal-blue'
        });
        $('.checkbox-toggle').on('ifChecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("check");
        });
        $('.checkbox-toggle').on('ifUnchecked', function(event){
            var _this = $(this);
            var _table = _this.closest('.table');
            _table.find("tr td input[type='checkbox']").iCheck("uncheck");
        });
    });
    function change_status(id) {
        $.ajax({
            url:"{:url('change_status')}",
            type:'post',
            data:{'id':id},
            success:function (res) {
                $.amaran({'message': res.msg});
                if(res.err == 0){
                    window.location.reload()
                }
            }
        });
    }
</script>


<!-- 递归填充分类  -->
<script>
    var eventList;
    $.ajax({
        type: 'get',
        url: "{:url('base/base_integral_cate')}",
        dataType:"json",
        async: false,
        success: function (data) {
            // console.log(data);
            eventList = data;
        }
    })
    
    var an_tree = ergodic(eventList);
    $(".an_tree").append(an_tree);
    function ergodic(data) {
        var content = '';
        $.each(data, function (index, value) {
            if (value.children != "") {
                var children = ergodic(value.children);
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"><i class="fa fa-caret-right"></i></span><span class="an_tree_txt" data_id="' + value.id + '">' + value.name + '</span><a class="btn btn-primary btn-xs" href="/company/integral/fixed_cate_edit/id/'+value.id+'"><i class="fa fa-edit"></i> 编辑</a><a class="btn btn-sm btn-danger audit-del" href="javascript:void(0);" data-url="/company/integral/fixed_cate_del" data-id="'+value.id+'"><i class="fa fa-trash"></i> 删除</a></div></div><div class="an_tree_pack">' + children + '</div></div>';
            } else {
                content += '<div class="an_tree_set"><div class="an_tree_entry"><div class="an_tree_main"><span class="an_tree_icon"></span><span class="an_tree_txt" data_id="' + value.id + '" data_pid="' + value.pid + '">' + value.name + '</span><a class="btn btn-primary btn-xs" href="/company/integral/fixed_cate_edit/id/'+value.id+'"><i class="fa fa-edit"></i> 编辑</a><a class="btn btn-sm btn-danger audit-del" href="javascript:void(0);" data-url="/company/integral/fixed_cate_del" data-id="'+value.id+'"><i class="fa fa-trash"></i> 删除</a></div></div><div class="an_tree_pack"></div></div>';
            }
        });
        return content;
    }
</script>
<!-- 树结构js操作 单选  -->
<script>
    $(".an_tree").on("click", ".fa", function () {
        $(this).toggleClass("fa-caret-down");
        $(this).toggleClass("fa-caret-right");
        $(this).parents(".an_tree_set").eq(0).children(".an_tree_pack").toggle();
    });
    $(".an_tree").on("click", ".an_tree_txt", function () {
        $(".an_tree").find(".tree_txt_active").removeClass("tree_txt_active");
        $(this).addClass("tree_txt_active");
        var department_id = $(this).attr("data_id");
        var department_name = $(this).html();
    });
    $(".an_tree .an_tree_list").on("click", ".an_list_item", function () {
        $(this).siblings().removeClass("list_item_check");
        $(this).toggleClass("list_item_check")
    })
</script>



{/block}
